/**
 * Created by Administrator on 2015/1/10.
 */
var logger = require('./logger');

var path = require('path');

module.exports.Config = function () {
    var templateDir = path.join(__dirname, "template");
    return {
        host: "0.0.0.0",
        port: 48080,
        paraserType: "text/xml",
        token: "chenshengli532",
        logger: "combined",
        weixinUser: "grabForGhost",
        appId: "wx1ab6f83cefc1339e",
        appSecret: "8547774504a9621e2cfce43e2c735afc",
        tokenBaseURL: "https://api.weixin.qq.com/cgi-bin/token",
        userInfoBaseURL: "https://api.weixin.qq.com/cgi-bin/user/info",
        favicon: "../public/img/favicon.ico",
        debug: true,
        replyText: "replyText",
        templateDir: templateDir,
        mongoInfo: {uri: "mongodb://127.0.0.1:27017/ghost", user: "ghostopr", pass: "pa888888"}
    };
}

module.exports.debugEnable = function () {
    return this.Config().debug;
}

module.exports.code404 = function (req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
}

module.exports.errorHandler = function (err, req, res, next) {
    logger.error("", err)
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: err
    });
}

module.exports.MongoCollection = {
    GAME: "games",
    USERS: "users",
    GAME_USERS:"usersOfGame"
};